<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
       
    // 5. 检测是否是本地电话，如010-12345678,0418-12345678
       var a = prompt("请输入电话号码（带区号）")
       var re = /^((010)|(028))-?\d{8}$/
       switch(re.test(a)) {
           case true:
               alert(a +"是一个本地号码");
               break;
           case false:
               alert(a + "不是一个本地号码");
               break;
       }

    </script>
</body>
</html>